package com.phison.fenestrapro.dashboard.util;

import com.phison.fenestrapro.dashboard.data.Project;
import com.vaadin.data.Item;
import com.vaadin.data.Property.ValueChangeEvent;
import com.vaadin.data.Property.ValueChangeListener;
import com.vaadin.data.validator.CompositeValidator;
import com.vaadin.data.validator.DoubleValidator;
import com.vaadin.data.validator.IntegerValidator;
import com.vaadin.ui.CheckBox;
import com.vaadin.ui.ComboBox;
import com.vaadin.ui.Component;
import com.vaadin.ui.DefaultFieldFactory;
import com.vaadin.ui.Field;
import com.vaadin.ui.Form;
import com.vaadin.ui.Slider;
import com.vaadin.ui.TextArea;
import com.vaadin.ui.TextField;

/**
 *
 * 
 * @author Niall O'Hara
 *
 */
@SuppressWarnings("serial")
public class MyFieldFactory extends DefaultFieldFactory implements GlobalConstants {

	Project project;
	
	private static final CompositeValidator doubleValidator = new CompositeValidator(
			CompositeValidator.MODE_AND, "The field must contain a number");

	private static final CompositeValidator integerValidator = new CompositeValidator(
			CompositeValidator.MODE_AND, "The field must contain a number");
	
	public MyFieldFactory(Project building) {

		this.project = building;
		
		doubleValidator.addValidator(new DoubleValidator("{0} is not number"));
		doubleValidator
				.addValidator(new RequiredValidator("Required Validator"));

		integerValidator
				.addValidator(new IntegerValidator("{0} is not number"));
		integerValidator.addValidator(new RequiredValidator(
				"Required Validator"));
		
	}
	
	public Field createField(Item item, Object propertyId,
			Component uiContext) {

 		final Form form = (Form) uiContext;

		final CheckBox checkbox = new CheckBox();

		if ("facadeOneGlazedAreaLock".equals(propertyId)) {
			checkbox.setCaption("Lock Fa�ade % Glazed");
			checkbox.setValue(project.isFacadeOneGlazedAreaLock());
			checkbox.addListener(new ValueChangeListener() {
				public void valueChange(ValueChangeEvent event) {
					Slider facadeOneGlazedPercentage = (Slider) form
							.getField("facadeOneGlazedPercentage");
					/*Slider facadeOnePercentageFrame = (Slider) form
							.getField("facadeOnePercentageFrame");
					Slider facadeOneWindowShadingDepth = (Slider) form
							.getField("facadeOneWindowShadingDepth");
					ComboBox facadeOneWindowGlazing = (ComboBox) form
							.getField("facadeOneWindowGlazing");
					ComboBox facadeOneWindowShadingType = (ComboBox) form
							.getField("facadeOneWindowShadingType");
					ComboBox facadeOneWindowConfig = (ComboBox) form
							.getField("facadeOneWindowConfig");
					ComboBox facadeOneShadingAngle = (ComboBox) form
							.getField("facadeOneShadingAngle");
					ComboBox facadeOneLouvreColour = (ComboBox) form
							.getField("facadeOneLouvreColour");
					ComboBox facadeOneSlatAngle = (ComboBox) form
							.getField("facadeOneSlatAngle");*/

					if (facadeOneGlazedPercentage == null) //|| facadeOnePercentageFrame == null || facadeOneWindowGlazing == null || facadeOneWindowShadingType == null || facadeOneWindowConfig == null || facadeOneWindowShadingDepth == null || facadeOneShadingAngle == null || facadeOneLouvreColour == null || facadeOneSlatAngle == null)
						return;
					Boolean selected = (Boolean) checkbox.getValue();
					facadeOneGlazedPercentage.setEnabled(!selected);
					/*facadeOnePercentageFrame.setEnabled(!selected);
					facadeOneWindowGlazing.setEnabled(!selected);
					facadeOneWindowShadingType.setEnabled(!selected);
					facadeOneWindowConfig.setEnabled(!selected);
					facadeOneWindowShadingDepth.setEnabled(!selected);
					facadeOneShadingAngle.setEnabled(!selected);
					facadeOneLouvreColour.setEnabled(!selected);
					facadeOneSlatAngle.setEnabled(!selected);*/
				}
			});
			return checkbox;

		} else if ("facadeTwoGlazedAreaLock".equals(propertyId)) {
			checkbox.setCaption("Lock Fa�ade % Glazed");
			checkbox.setValue(project.isFacadeTwoGlazedAreaLock());
			checkbox.addListener(new ValueChangeListener() {
				public void valueChange(ValueChangeEvent event) {
					Slider facadeTwoGlazedPercentage = (Slider) form
							.getField("facadeTwoGlazedPercentage");
					/*Slider facadeTwoPercentageFrame = (Slider) form
							.getField("facadeTwoPercentageFrame");
					Slider facadeTwoWindowShadingDepth = (Slider) form
							.getField("facadeTwoWindowShadingDepth");
					ComboBox facadeTwoWindowGlazing = (ComboBox) form
							.getField("facadeTwoWindowGlazing");
					ComboBox facadeTwoWindowShadingType = (ComboBox) form
							.getField("facadeTwoWindowShadingType");
					ComboBox facadeTwoWindowConfig = (ComboBox) form
							.getField("facadeTwoWindowConfig");
					ComboBox facadeTwoShadingAngle = (ComboBox) form
							.getField("facadeTwoShadingAngle");
					ComboBox facadeTwoLouvreColour = (ComboBox) form
							.getField("facadeTwoLouvreColour");
					ComboBox facadeTwoSlatAngle = (ComboBox) form
							.getField("facadeTwoSlatAngle");*/

					if (facadeTwoGlazedPercentage == null) // || facadeTwoPercentageFrame == null || facadeTwoWindowGlazing == null || facadeTwoWindowShadingType == null || facadeTwoWindowConfig == null || facadeTwoWindowShadingDepth == null || facadeTwoShadingAngle == null || facadeTwoLouvreColour == null || facadeTwoSlatAngle == null)
						return;
					Boolean selected = (Boolean) checkbox.getValue();
					facadeTwoGlazedPercentage.setEnabled(!selected);
					/*facadeTwoPercentageFrame.setEnabled(!selected);
					facadeTwoWindowGlazing.setEnabled(!selected);
					facadeTwoWindowShadingType.setEnabled(!selected);
					facadeTwoWindowConfig.setEnabled(!selected);
					facadeTwoWindowShadingDepth.setEnabled(!selected);
					facadeTwoShadingAngle.setEnabled(!selected);
					facadeTwoLouvreColour.setEnabled(!selected);
					facadeTwoSlatAngle.setEnabled(!selected);*/
				}
			});
			return checkbox;

		} else if ("facadeThreeGlazedAreaLock".equals(propertyId)) {
			checkbox.setCaption("Lock Fa�ade % Glazed");
			checkbox.setValue(project.isFacadeThreeGlazedAreaLock());
			checkbox.addListener(new ValueChangeListener() {
				public void valueChange(ValueChangeEvent event) {
					Slider facadeThreeGlazedPercentage = (Slider) form
							.getField("facadeThreeGlazedPercentage");
					/*Slider facadeThreePercentageFrame = (Slider) form
							.getField("facadeThreePercentageFrame");
					Slider facadeThreeWindowShadingDepth = (Slider) form
							.getField("facadeThreeWindowShadingDepth");
					ComboBox facadeThreeWindowGlazing = (ComboBox) form
							.getField("facadeThreeWindowGlazing");
					ComboBox facadeThreeWindowShadingType = (ComboBox) form
							.getField("facadeThreeWindowShadingType");
					ComboBox facadeThreeWindowConfig = (ComboBox) form
							.getField("facadeThreeWindowConfig");
					ComboBox facadeThreeShadingAngle = (ComboBox) form
							.getField("facadeThreeShadingAngle");
					ComboBox facadeThreeLouvreColour = (ComboBox) form
							.getField("facadeThreeLouvreColour");
					ComboBox facadeThreeSlatAngle = (ComboBox) form
							.getField("facadeThreeSlatAngle");*/

					if (facadeThreeGlazedPercentage == null) //|| facadeThreePercentageFrame == null || facadeThreeWindowGlazing == null || facadeThreeWindowShadingType == null || facadeThreeWindowConfig == null || facadeThreeWindowShadingDepth == null || facadeThreeShadingAngle == null || facadeThreeLouvreColour == null || facadeThreeSlatAngle == null)
						return;
					Boolean selected = (Boolean) checkbox.getValue();
					facadeThreeGlazedPercentage.setEnabled(!selected);
					/*facadeThreePercentageFrame.setEnabled(!selected);
					facadeThreeWindowGlazing.setEnabled(!selected);
					facadeThreeWindowShadingType.setEnabled(!selected);
					facadeThreeWindowConfig.setEnabled(!selected);
					facadeThreeWindowShadingDepth.setEnabled(!selected);
					facadeThreeShadingAngle.setEnabled(!selected);
					facadeThreeLouvreColour.setEnabled(!selected);
					facadeThreeSlatAngle.setEnabled(!selected);*/
				}
			});
			return checkbox;
			
		} else if ("facadeFourGlazedAreaLock".equals(propertyId)) {
			checkbox.setCaption("Lock Fa�ade % Glazed");
			checkbox.setValue(project.isFacadeFourGlazedAreaLock());
			checkbox.addListener(new ValueChangeListener() {
				public void valueChange(ValueChangeEvent event) {
					Slider facadeFourGlazedPercentage = (Slider) form
							.getField("facadeFourGlazedPercentage");
					/*Slider facadeFourPercentageFrame = (Slider) form
							.getField("facadeFourPercentageFrame");
					Slider facadeFourWindowShadingDepth = (Slider) form
							.getField("facadeFourWindowShadingDepth");
					ComboBox facadeFourWindowGlazing = (ComboBox) form
							.getField("facadeFourWindowGlazing");
					ComboBox facadeFourWindowShadingType = (ComboBox) form
							.getField("facadeFourWindowShadingType");
					ComboBox facadeFourWindowConfig = (ComboBox) form
							.getField("facadeFourWindowConfig");
					ComboBox facadeFourShadingAngle = (ComboBox) form
							.getField("facadeFourShadingAngle");
					ComboBox facadeFourLouvreColour = (ComboBox) form
							.getField("facadeFourLouvreColour");
					ComboBox facadeFourSlatAngle = (ComboBox) form
							.getField("facadeFourSlatAngle");*/

					if (facadeFourGlazedPercentage == null) // || facadeFourPercentageFrame == null || facadeFourWindowGlazing == null || facadeFourWindowShadingType == null || facadeFourWindowConfig == null || facadeFourWindowShadingDepth == null || facadeFourShadingAngle == null || facadeFourLouvreColour == null || facadeFourSlatAngle == null)
						return;
					Boolean selected = (Boolean) checkbox.getValue();
					facadeFourGlazedPercentage.setEnabled(!selected);
					/*facadeFourPercentageFrame.setEnabled(!selected);
					facadeFourWindowGlazing.setEnabled(!selected);
					facadeFourWindowShadingType.setEnabled(!selected);
					facadeFourWindowConfig.setEnabled(!selected);
					facadeFourWindowShadingDepth.setEnabled(!selected);
					facadeFourShadingAngle.setEnabled(!selected);
					facadeFourLouvreColour.setEnabled(!selected);
					facadeFourSlatAngle.setEnabled(!selected);*/
				}
			});
			return checkbox;
			
		} else if ("applyToFacadeOne"
				.equals(propertyId)) {
			checkbox.setCaption("Apply Values to Fa�ade One");
			checkbox.addListener(new ValueChangeListener() {
				public void valueChange(ValueChangeEvent event) {
					
				}
			});
			return checkbox;
			
		} else if ("applyToFacadeTwo"
				.equals(propertyId)) {
			checkbox.setCaption("Apply Values to Fa�ade Two");
			checkbox.addListener(new ValueChangeListener() {
				public void valueChange(ValueChangeEvent event) {
					
				}
			});
			return checkbox;
			
		} else if ("applyToFacadeThree"
				.equals(propertyId)) {
			checkbox.setCaption("Apply Values to Fa�ade Three");
			checkbox.addListener(new ValueChangeListener() {
				public void valueChange(ValueChangeEvent event) {
					
				}
			});
			return checkbox;
			
		} else if ("applyToFacadeFour"
				.equals(propertyId)) {
			checkbox.setCaption("Apply Values to Fa�ade Four");
			checkbox.addListener(new ValueChangeListener() {
				public void valueChange(ValueChangeEvent event) {
					
				}
			});
			return checkbox;
		} else if ("setSave"
				.equals(propertyId)) {
			checkbox.setCaption("Save Project");
			checkbox.addListener(new ValueChangeListener() {
				public void valueChange(ValueChangeEvent event) {
					
				}
			});
			return checkbox;
		}
		
		Field field = super.createField(item, propertyId, uiContext);

		((TextField) field).setRequired(true);

		if ("storeys".equals(propertyId)) {
			
			final ComboBox storeys = new ComboBox("storeys");
			
			storeys.setNullSelectionAllowed(false);
			storeys.setInputPrompt("-- Select Building Storeys --");
			for (int i = 1; i < maxStoreys + 1; i++) {
				storeys.addItem(i);
			}
			storeys.setWidth("100%");
			storeys.setCaption("Storeys");

			storeys.addListener(new ValueChangeListener() {
				public void valueChange(ValueChangeEvent event) {
					Integer selected = (Integer) storeys.getValue();

					if (selected == null)
						return;

					String leadingZero = null;
					
					int numFloors = selected - 1;
					
					for (int i = maxStoreys - 1; i > numFloors; i--) {
						if (i < 10) {
							leadingZero = "0";
						} else {
							leadingZero = "";
						}
						try {	form.getField("floor" + i).setVisible(false);				} catch (java.lang.NullPointerException e) {};
						try {	form.getField("facadeOneWindowHH" + leadingZero + i).setVisible(false);	} catch (java.lang.NullPointerException e) {};
						try { 	form.getField("facadeTwoWindowHH" + leadingZero + i).setVisible(false);	} catch (java.lang.NullPointerException e) {};
						try { 	form.getField("facadeThreeWindowHH" + leadingZero + i).setVisible(false);	} catch (java.lang.NullPointerException e) {};
						try { 	form.getField("facadeFourWindowHH" + leadingZero + i).setVisible(false);	} catch (java.lang.NullPointerException e) {};
						try { 	form.getField("facadeOneWindowCH" + leadingZero + i).setVisible(false);	} catch (java.lang.NullPointerException e) {};
						try { 	form.getField("facadeTwoWindowCH" + leadingZero + i).setVisible(false);	} catch (java.lang.NullPointerException e) {};
						try { 	form.getField("facadeThreeWindowCH" + leadingZero + i).setVisible(false);	} catch (java.lang.NullPointerException e) {};
						try { 	form.getField("facadeFourWindowCH" + leadingZero + i).setVisible(false);	} catch (java.lang.NullPointerException e) {};
						try { 	form.getField("facadeOneWindowRV" + leadingZero + i).setVisible(false);	} catch (java.lang.NullPointerException e) {};
						try { 	form.getField("facadeTwoWindowRV" + leadingZero + i).setVisible(false);	} catch (java.lang.NullPointerException e) {};
						try { 	form.getField("facadeThreeWindowRV" + leadingZero + i).setVisible(false);	} catch (java.lang.NullPointerException e) {};
						try { 	form.getField("facadeFourWindowRV" + leadingZero + i).setVisible(false);	} catch (java.lang.NullPointerException e) {};
					}
					
					for (int i = 0; i <= numFloors; i++) {
						if (i < 10) {
							leadingZero = "0";
						} else {
							leadingZero = "";
						}
						try {	form.getField("floor" + i).setVisible(true);				} catch (java.lang.NullPointerException e) {};
						try {	form.getField("facadeOneWindowHH" + leadingZero + i).setVisible(true);	} catch (java.lang.NullPointerException e) {};
						try { 	form.getField("facadeTwoWindowHH" + leadingZero + i).setVisible(true);	} catch (java.lang.NullPointerException e) {};
						try { 	form.getField("facadeThreeWindowHH" + leadingZero + i).setVisible(true);	} catch (java.lang.NullPointerException e) {};
						try { 	form.getField("facadeFourWindowHH" + leadingZero + i).setVisible(true);	} catch (java.lang.NullPointerException e) {};
						try { 	form.getField("facadeOneWindowCH" + leadingZero + i).setVisible(true);	} catch (java.lang.NullPointerException e) {};
						try { 	form.getField("facadeTwoWindowCH" + leadingZero + i).setVisible(true);	} catch (java.lang.NullPointerException e) {};
						try { 	form.getField("facadeThreeWindowCH" + leadingZero + i).setVisible(true);	} catch (java.lang.NullPointerException e) {};
						try { 	form.getField("facadeFourWindowCH" + leadingZero + i).setVisible(true);	} catch (java.lang.NullPointerException e) {};
						try { 	form.getField("facadeOneWindowRV" + leadingZero + i).setVisible(true);	} catch (java.lang.NullPointerException e) {};
						try { 	form.getField("facadeTwoWindowRV" + leadingZero + i).setVisible(true);	} catch (java.lang.NullPointerException e) {};
						try { 	form.getField("facadeThreeWindowRV" + leadingZero + i).setVisible(true);	} catch (java.lang.NullPointerException e) {};
						try { 	form.getField("facadeFourWindowRV" + leadingZero + i).setVisible(true);	} catch (java.lang.NullPointerException e) {};
					}

				}
			});
			
			return storeys;

		} else if ("maxPercentageGlazing".equals(propertyId)) {
			((TextField) field).setCaption("Maximum Allowable Glazing [" + UNIT_perc + "]");
			((TextField) field).addListener(new ValueChangeListener() {
				public void valueChange(ValueChangeEvent event) {
					Slider slider = (Slider) form
							.getField("percentageGlazing");

					if (slider == null)
						return;

					slider.setMax(project.getMaxPercentageGlazing());
				}
			});

		} else if ("maxAverageUvalueFacade".equals(propertyId)) {
			((TextField) field).setCaption("Minimum Standard [" + UNIT_wm2k + "]");
			((TextField) field).addListener(new ValueChangeListener() {
				public void valueChange(ValueChangeEvent event) {
					Slider slider = (Slider) form
							.getField("facadePerformance");

					if (slider == null)
						return;

					slider.setMax(project.getMaxAverageUvalueFacade());
				}
			});

		} else if ("totalGlazedArea".equals(propertyId)) {
			((TextField) field).addListener(new ValueChangeListener() {
				public void valueChange(ValueChangeEvent event) {

					Slider facadeOnePercentageTotalGlazedArea = (Slider) form
							.getField("facadeOnePercentageTotalGlazedArea");
					Slider facadeTwoPercentageTotalGlazedArea = (Slider) form
							.getField("facadeTwoPercentageTotalGlazedArea");
					Slider facadeThreePercentageTotalGlazedArea = (Slider) form
							.getField("facadeThreePercentageTotalGlazedArea");
					Slider facadeFourPercentageTotalGlazedArea = (Slider) form
							.getField("facadeFourPercentageTotalGlazedArea");

					if (facadeOnePercentageTotalGlazedArea == null
							|| facadeTwoPercentageTotalGlazedArea == null
							|| facadeThreePercentageTotalGlazedArea == null
							|| facadeFourPercentageTotalGlazedArea == null)
						return;

					facadeOnePercentageTotalGlazedArea.setMax(Math.min(
							100,
							(project.getFacadeOneArea() / project
									.getTotalGlazedArea()) * 100));
					facadeTwoPercentageTotalGlazedArea.setMax(Math.min(
							100,
							(project.getFacadeTwoArea() / project
									.getTotalGlazedArea()) * 100));
					facadeThreePercentageTotalGlazedArea.setMax(Math.min(
							100,
							(project.getFacadeThreeArea() / project
									.getTotalGlazedArea()) * 100));
					facadeFourPercentageTotalGlazedArea.setMax(Math.min(
							100,
							(project.getFacadeFourArea() / project
									.getTotalGlazedArea()) * 100));

				}
			});

		} else if ("buildingType".equals(propertyId)) {
			
			final ComboBox buildingType = new ComboBox("buildingType");
			
			buildingType.setNullSelectionAllowed(false);
			buildingType.setInputPrompt("-- Select a Building Type --");
			for (int i = 0; i < buildingTypeArray.length; i++) {
				buildingType.addItem(buildingTypeArray[i]);
			}
			buildingType.setWidth("100%");
			buildingType.setCaption("Building Type");

			buildingType.addListener(new ValueChangeListener() {
				public void valueChange(ValueChangeEvent event) {
					String selected = (String) buildingType.getValue();

					if (selected == null)
						return;

				}
			});

			return buildingType;

		} else if ("facadeType".equals(propertyId)) {
			
			final ComboBox facadeType = new ComboBox("facadeType");
			
			facadeType.setNullSelectionAllowed(false);
			facadeType.setInputPrompt("-- Select a Fa�ade Type --");
			for (int i = 0; i < facadeTypeArray.length; i++) {
				facadeType.addItem(facadeTypeArray[i]);
			}
			facadeType.setWidth("100%");
			facadeType.setCaption("Facade Type");

			facadeType.addListener(new ValueChangeListener() {
				public void valueChange(ValueChangeEvent event) {
					String selected = (String) facadeType.getValue();
					Slider slideruValueRoof = (Slider) form
							.getField("uValueRoof");
					Slider slideruValueGroundFloor = (Slider) form
							.getField("uValueGroundFloor");
					Slider slideruValueWalls = (Slider) form
							.getField("uValueWalls");
					Slider slideruValueGlazing = (Slider) form
							.getField("uValueGlazing");

					if (selected == null || slideruValueRoof == null
							|| slideruValueGroundFloor == null
							|| slideruValueWalls == null
							|| slideruValueGlazing == null)
						return;

					//TODO: these should not be set here as they are not loaded at runtime
					if ((FT_NB).equals(selected)) {
						slideruValueRoof.setMin(0.1d);
						slideruValueRoof.setMax(0.25d);
						slideruValueGroundFloor.setMin(0.1d);
						slideruValueGroundFloor.setMax(0.37d);
						slideruValueWalls.setMin(0.1d);
						slideruValueWalls.setMax(0.27d);
						slideruValueGlazing.setMin(0.6d);
						slideruValueGlazing.setMax(2.20d);
					} else if ((FT_REP).equals(selected)
							|| (FT_REF).equals(selected)) {
						slideruValueRoof.setMin(0.1d);
						slideruValueRoof.setMax(0.35d);
						slideruValueGroundFloor.setMin(0.1d);
						slideruValueGroundFloor.setMax(0.6d);
						slideruValueWalls.setMin(0.1d);
						slideruValueWalls.setMax(0.6d);
						slideruValueGlazing.setMin(0.6d);
						slideruValueGlazing.setMax(2.20d);
					}
				}
			});

			return facadeType;

		} else if ("locationSetting".equals(propertyId)) {
			
			final ComboBox locationSetting = new ComboBox("locationSetting");
			
			locationSetting.setNullSelectionAllowed(false);
			locationSetting.setInputPrompt("-- Select a Location Setting --");
			for (int i = 0; i < locationSettingArray.length; i++) {
				locationSetting.addItem(locationSettingArray[i]);
			}
			locationSetting.setWidth("100%");
			locationSetting.setCaption("Location Setting");

			locationSetting.addListener(new ValueChangeListener() {
				public void valueChange(ValueChangeEvent event) {
					String selected = (String) locationSetting.getValue();

					if (selected == null)
						return;

				}
			});
			
			return locationSetting;
			
		} else if ("orientation".equals(propertyId)) {
			
			final ComboBox orientation = new ComboBox("orientation");
			
			orientation.setNullSelectionAllowed(false);
			orientation.setInputPrompt("-- Select an Orientation --");
			for (int i = 0; i < orientationArray.length; i++) {
				orientation.addItem(orientationArray[i]);
			}
			orientation.setCaption("Orientation");
			orientation.setWidth("100%");

			orientation.addListener(new ValueChangeListener() {
				public void valueChange(ValueChangeEvent event) {
					
					String selected = (String) orientation.getValue();
					
					Slider facadeOneGlazedPercentage = (Slider) form.getField("facadeOneGlazedPercentage");
					if (selected != null && facadeOneGlazedPercentage != null)
						facadeOneGlazedPercentage.setCaption(/*building.getFacadeOneOrientation() + " */ "Fa�ade % Glazed");
					
					Slider facadeTwoGlazedPercentage = (Slider) form.getField("facadeTwoGlazedPercentage");
					if (selected != null && facadeTwoGlazedPercentage != null)
						facadeTwoGlazedPercentage.setCaption(/*building.getFacadeTwoOrientation() + " */ "Fa�ade % Glazed");
					
					Slider facadeThreeGlazedPercentage = (Slider) form.getField("facadeThreeGlazedPercentage");
					if (selected != null && facadeThreeGlazedPercentage != null)
						facadeThreeGlazedPercentage.setCaption(/*building.getFacadeThreeOrientation() + " */ "Fa�ade % Glazed");
					
					Slider facadeFourGlazedPercentage = (Slider) form.getField("facadeFourGlazedPercentage");
					if (selected != null && facadeFourGlazedPercentage != null)
						facadeFourGlazedPercentage.setCaption(/*building.getFacadeFourOrientation() + " */ "Fa�ade % Glazed");
					
					TextField facadeOneGlazedPercentageValue = (TextField) form.getField("facadeOneGlazedPercentageValue");
					if (selected != null && facadeOneGlazedPercentageValue != null)
						facadeOneGlazedPercentageValue.setCaption(project.getFacadeOneOrientation() + " Fa�ade % Glazed");
					
					TextField facadeTwoGlazedPercentageValue = (TextField) form.getField("facadeTwoGlazedPercentageValue");
					if (selected != null && facadeTwoGlazedPercentageValue != null)
						facadeTwoGlazedPercentageValue.setCaption(project.getFacadeTwoOrientation() + " Fa�ade % Glazed");
					
					TextField facadeThreeGlazedPercentageValue = (TextField) form.getField("facadeThreeGlazedPercentageValue");
					if (selected != null && facadeThreeGlazedPercentageValue != null)
						facadeThreeGlazedPercentageValue.setCaption(project.getFacadeThreeOrientation() + " Fa�ade % Glazed");
					
					TextField facadeFourGlazedPercentageValue = (TextField) form.getField("facadeFourGlazedPercentageValue");
					if (selected != null && facadeFourGlazedPercentageValue != null)
						facadeFourGlazedPercentageValue.setCaption(project.getFacadeFourOrientation() + " Fa�ade % Glazed");
					
					TextField facadeOneSurroundingFeaturesAverageHeight = (TextField) form.getField("facadeOneSurroundingFeaturesAverageHeight");
					if (selected != null && facadeOneSurroundingFeaturesAverageHeight != null)
						facadeOneSurroundingFeaturesAverageHeight.setCaption("Surrounding Features Avg. Height [" + UNIT_m + "]");

					TextField facadeTwoSurroundingFeaturesAverageHeight = (TextField) form.getField("facadeTwoSurroundingFeaturesAverageHeight");
					if (selected != null && facadeTwoSurroundingFeaturesAverageHeight != null)
						facadeTwoSurroundingFeaturesAverageHeight.setCaption("Surrounding Features Avg. Height [" + UNIT_m + "]");
					
					TextField facadeThreeSurroundingFeaturesAverageHeight = (TextField) form.getField("facadeThreeSurroundingFeaturesAverageHeight");
					if (selected != null && facadeThreeSurroundingFeaturesAverageHeight != null)
						facadeThreeSurroundingFeaturesAverageHeight.setCaption("Surrounding Features Avg. Height [" + UNIT_m + "]");
			
					TextField facadeFourSurroundingFeaturesAverageHeight = (TextField) form.getField("facadeFourSurroundingFeaturesAverageHeight");
					if (selected != null && facadeFourSurroundingFeaturesAverageHeight != null)
						facadeFourSurroundingFeaturesAverageHeight.setCaption("Surrounding Features Avg. Height [" + UNIT_m + "]");
					
					TextField facadeOneSurroundingFeaturesAverageDistance = (TextField) form.getField("facadeOneSurroundingFeaturesAverageDistance");
					if (selected != null && facadeOneSurroundingFeaturesAverageDistance != null)
						facadeOneSurroundingFeaturesAverageDistance.setCaption("Surrounding Features Avg. Distance [" + UNIT_m + "]");
					
					TextField facadeTwoSurroundingFeaturesAverageDistance = (TextField) form.getField("facadeTwoSurroundingFeaturesAverageDistance");
					if (selected != null && facadeTwoSurroundingFeaturesAverageDistance != null)
						facadeTwoSurroundingFeaturesAverageDistance.setCaption("Surrounding Features Avg. Distance [" + UNIT_m + "]");
					
					TextField facadeThreeSurroundingFeaturesAverageDistance = (TextField) form.getField("facadeThreeSurroundingFeaturesAverageDistance");
					if (selected != null && facadeThreeSurroundingFeaturesAverageDistance != null)
						facadeThreeSurroundingFeaturesAverageDistance.setCaption("Surrounding Features Avg. Distance [" + UNIT_m + "]");
					
					TextField facadeFourSurroundingFeaturesAverageDistance = (TextField) form.getField("facadeFourSurroundingFeaturesAverageDistance");
					if (selected != null && facadeFourSurroundingFeaturesAverageDistance != null)
						facadeFourSurroundingFeaturesAverageDistance.setCaption("Surrounding Features Avg. Distance [" + UNIT_m + "]");
					
					TextField facadeOneAvgDailySolarLoadPerFloorValue = (TextField) form.getField("facadeOneAvgDailySolarLoadPerFloorValue");
					if (selected != null && facadeOneAvgDailySolarLoadPerFloorValue != null)
						facadeOneAvgDailySolarLoadPerFloorValue.setCaption(project.getFacadeOneOrientation() + " Fa�ade - Average Daily Solar Load per Floor");
					
					TextField facadeTwoAvgDailySolarLoadPerFloorValue = (TextField) form.getField("facadeTwoAvgDailySolarLoadPerFloorValue");
					if (selected != null && facadeTwoAvgDailySolarLoadPerFloorValue != null)
						facadeTwoAvgDailySolarLoadPerFloorValue.setCaption(project.getFacadeTwoOrientation() + " Fa�ade - Average Daily Solar Load per Floor");
					
					TextField facadeThreeAvgDailySolarLoadPerFloorValue = (TextField) form.getField("facadeThreeAvgDailySolarLoadPerFloorValue");
					if (selected != null && facadeThreeAvgDailySolarLoadPerFloorValue != null)
						facadeThreeAvgDailySolarLoadPerFloorValue.setCaption(project.getFacadeThreeOrientation() + " Fa�ade - Average Daily Solar Load per Floor");
					
					TextField facadeFourAvgDailySolarLoadPerFloorValue = (TextField) form.getField("facadeFourAvgDailySolarLoadPerFloorValue");
					if (selected != null && facadeFourAvgDailySolarLoadPerFloorValue != null)
						facadeFourAvgDailySolarLoadPerFloorValue.setCaption(project.getFacadeFourOrientation() + " Fa�ade - Average Daily Solar Load per Floor");
					
				}
			});

			return orientation;
			
		} else if ("windowGlazing".equals(propertyId)) {
			
			final ComboBox windowGlazing = new ComboBox("windowGlazing");
			
			windowGlazing.setNullSelectionAllowed(false);
			windowGlazing.setInputPrompt("-- Select Solar Transmittance --");
			for (int i = 0; i < solarTransArray.length; i++) {
				windowGlazing.addItem(solarTransArray[i]);
			}
			windowGlazing.setWidth("100%");
			windowGlazing.setCaption("Solar Trans.");

			windowGlazing.addListener(new ValueChangeListener() {
				public void valueChange(ValueChangeEvent event) {
					String selected = (String) windowGlazing.getValue();

					if (selected == null)
						return;
					
				}
			});

			return windowGlazing;	
			
		} else if ("facadeOneWindowGlazing".equals(propertyId)) {
			
			final ComboBox facadeOneWindowGlazing = new ComboBox("facadeOneWindowGlazing");
			
			facadeOneWindowGlazing.setNullSelectionAllowed(false);
			facadeOneWindowGlazing.setInputPrompt("-- Select Solar Transmittance --");
			for (int i = 0; i < solarTransArray.length; i++) {
				facadeOneWindowGlazing.addItem(solarTransArray[i]);
			}
			facadeOneWindowGlazing.setWidth("100%");
			facadeOneWindowGlazing.setCaption("Solar Trans.");

			facadeOneWindowGlazing.addListener(new ValueChangeListener() {
				public void valueChange(ValueChangeEvent event) {
					String selected = (String) facadeOneWindowGlazing.getValue();

					if (selected == null)
						return;
					
				}
			});

			return facadeOneWindowGlazing;	
			
		} else if ("facadeTwoWindowGlazing".equals(propertyId)) {
			
			final ComboBox facadeTwoWindowGlazing = new ComboBox("facadeTwoWindowGlazing");
			
			facadeTwoWindowGlazing.setNullSelectionAllowed(false);
			facadeTwoWindowGlazing.setInputPrompt("-- Select Solar Transmittance --");
			for (int i = 0; i < solarTransArray.length; i++) {
				facadeTwoWindowGlazing.addItem(solarTransArray[i]);
			}
			facadeTwoWindowGlazing.setWidth("100%");
			facadeTwoWindowGlazing.setCaption("Solar Trans.");

			facadeTwoWindowGlazing.addListener(new ValueChangeListener() {
				public void valueChange(ValueChangeEvent event) {
					String selected = (String) facadeTwoWindowGlazing.getValue();

					if (selected == null)
						return;
					
				}
			});

			return facadeTwoWindowGlazing;	
			
		} else if ("facadeThreeWindowGlazing".equals(propertyId)) {
			
			final ComboBox facadeThreeWindowGlazing = new ComboBox("facadeThreeWindowGlazing");
			
			facadeThreeWindowGlazing.setNullSelectionAllowed(false);
			facadeThreeWindowGlazing.setInputPrompt("-- Select Solar Transmittance --");
			for (int i = 0; i < solarTransArray.length; i++) {
				facadeThreeWindowGlazing.addItem(solarTransArray[i]);
			}
			facadeThreeWindowGlazing.setWidth("100%");
			facadeThreeWindowGlazing.setCaption("Solar Trans.");

			facadeThreeWindowGlazing.addListener(new ValueChangeListener() {
				public void valueChange(ValueChangeEvent event) {
					String selected = (String) facadeThreeWindowGlazing.getValue();

					if (selected == null)
						return;
					
				}
			});

			return facadeThreeWindowGlazing;
			
		} else if ("facadeFourWindowGlazing".equals(propertyId)) {
			
			final ComboBox facadeFourWindowGlazing = new ComboBox("facadeFourWindowGlazing");
			
			facadeFourWindowGlazing.setNullSelectionAllowed(false);
			facadeFourWindowGlazing.setInputPrompt("-- Select Solar Transmittance --");
			for (int i = 0; i < solarTransArray.length; i++) {
				facadeFourWindowGlazing.addItem(solarTransArray[i]);
			}
			facadeFourWindowGlazing.setWidth("100%");
			facadeFourWindowGlazing.setCaption("Solar Trans.");

			facadeFourWindowGlazing.addListener(new ValueChangeListener() {
				public void valueChange(ValueChangeEvent event) {
					String selected = (String) facadeFourWindowGlazing.getValue();

					if (selected == null)
						return;
					
				}
			});

			return facadeFourWindowGlazing;
			
		} else if ("windowShadingType".equals(propertyId)) {
			
			final ComboBox windowShadingType = new ComboBox("windowShadingType");
			
			windowShadingType.setNullSelectionAllowed(false);
			windowShadingType.setInputPrompt("-- Select Shading Type --");
			for (int i = 0; i < shadingTypeArray.length; i++) {
				windowShadingType.addItem(shadingTypeArray[i]);
			}
			windowShadingType.setWidth("100%");
			windowShadingType.setCaption("Shading Type");

			windowShadingType.addListener(new ValueChangeListener() {
				public void valueChange(ValueChangeEvent event) {
					String selected = (String) windowShadingType.getValue();
					Slider windowDepth = (Slider) form.getField("windowDepth");
					ComboBox louvreColour = (ComboBox) form.getField("louvreColour");
					ComboBox slatAngle = (ComboBox) form.getField("slatAngle");
					ComboBox shadingAngle = (ComboBox) form.getField("shadingAngle");
					ComboBox windowConfig = (ComboBox) form.getField("windowConfig");
					
					if (selected == null || windowDepth == null || shadingAngle == null
							|| louvreColour == null || slatAngle == null)
						return;
					
					if ((NONE).equals(selected)) {
						windowConfig.setVisible(false);
						windowDepth.setVisible(false);
						shadingAngle.setVisible(false);
						louvreColour.setVisible(false);
						slatAngle.setVisible(false);
					} else if ((HSCO).equals(selected)) {
						windowConfig.setVisible(true);
						windowDepth.setVisible(true);
						shadingAngle.setVisible(false);
						louvreColour.setVisible(false);
						slatAngle.setVisible(false);
					} else if ((SSCO).equals(selected)) {
						windowConfig.setVisible(true);
						windowDepth.setVisible(true);
						shadingAngle.setVisible(true);
						louvreColour.setVisible(false);
						slatAngle.setVisible(false);
					} else if ((HEL).equals(selected)) {
						windowConfig.setVisible(false);
						windowDepth.setVisible(false);
						shadingAngle.setVisible(false);
						louvreColour.setVisible(true);
						slatAngle.setVisible(true);
					}
				}
			});

			return windowShadingType;
			
		} else if ("facadeOneWindowShadingType".equals(propertyId)) {
			
			final ComboBox facadeOneWindowShadingType = new ComboBox("facadeOneWindowShadingType");
			
			facadeOneWindowShadingType.setNullSelectionAllowed(false);
			facadeOneWindowShadingType.setInputPrompt("-- Select Shading Type --");
			for (int i = 0; i < shadingTypeArray.length; i++) {
				facadeOneWindowShadingType.addItem(shadingTypeArray[i]);
			}
			facadeOneWindowShadingType.setWidth("100%");
			facadeOneWindowShadingType.setCaption("Shading Type");

			if (project.getFacadeOneWindowShadingType() != null) {
				facadeOneWindowShadingType.setValue(project.getFacadeOneWindowShadingType());
			}

			facadeOneWindowShadingType.addListener(new ValueChangeListener() {
				public void valueChange(ValueChangeEvent event) {
					String selected = (String) facadeOneWindowShadingType.getValue();
					Slider windowDepth = (Slider) form.getField("facadeOneWindowShadingDepth");
					ComboBox louvreColour = (ComboBox) form.getField("facadeOneLouvreColour");
					ComboBox slatAngle = (ComboBox) form.getField("facadeOneSlatAngle");
					ComboBox shadingAngle = (ComboBox) form.getField("facadeOneShadingAngle");
					ComboBox windowConfig = (ComboBox) form.getField("facadeOneWindowConfig");
					
					if (selected == null || windowDepth == null || shadingAngle == null
							|| louvreColour == null || slatAngle == null)
						return;
					
					if ((NONE).equals(selected)) {
						windowConfig.setVisible(false);
						windowDepth.setVisible(false);
						shadingAngle.setVisible(false);
						louvreColour.setVisible(false);
						slatAngle.setVisible(false);
					} else if ((HSCO).equals(selected)) {
						windowConfig.setVisible(true);
						windowDepth.setVisible(true);
						shadingAngle.setVisible(false);
						louvreColour.setVisible(false);
						slatAngle.setVisible(false);
					} else if ((SSCO).equals(selected)) {
						windowConfig.setVisible(true);
						windowDepth.setVisible(true);
						shadingAngle.setVisible(true);
						louvreColour.setVisible(false);
						slatAngle.setVisible(false);
					} else if ((HEL).equals(selected)) {
						windowConfig.setVisible(false);
						windowDepth.setVisible(false);
						shadingAngle.setVisible(false);
						louvreColour.setVisible(true);
						slatAngle.setVisible(true);
					}
				}
			});

			return facadeOneWindowShadingType;
			
		} else if ("facadeTwoWindowShadingType".equals(propertyId)) {
			
			final ComboBox facadeTwoWindowShadingType = new ComboBox("facadeTwoWindowShadingType");
			
			facadeTwoWindowShadingType.setNullSelectionAllowed(false);
			facadeTwoWindowShadingType.setInputPrompt("-- Select Shading Type --");
			for (int i = 0; i < shadingTypeArray.length; i++) {
				facadeTwoWindowShadingType.addItem(shadingTypeArray[i]);
			}
			facadeTwoWindowShadingType.setWidth("100%");
			facadeTwoWindowShadingType.setCaption("Shading Type");

			if (project.getFacadeTwoWindowShadingType() != null) {
				facadeTwoWindowShadingType.setValue(project.getFacadeTwoWindowShadingType());
			}
			
			facadeTwoWindowShadingType.addListener(new ValueChangeListener() {
				public void valueChange(ValueChangeEvent event) {
					String selected = (String) facadeTwoWindowShadingType.getValue();
					Slider windowDepth = (Slider) form.getField("facadeTwoWindowShadingDepth");
					ComboBox louvreColour = (ComboBox) form.getField("facadeTwoLouvreColour");
					ComboBox slatAngle = (ComboBox) form.getField("facadeTwoSlatAngle");
					ComboBox shadingAngle = (ComboBox) form.getField("facadeTwoShadingAngle");
					ComboBox windowConfig = (ComboBox) form.getField("facadeTwoWindowConfig");
					
					if (selected == null || windowDepth == null || shadingAngle == null
							|| louvreColour == null || slatAngle == null)
						return;
					
					if ((NONE).equals(selected)) {
						windowConfig.setVisible(false);
						windowDepth.setVisible(false);
						shadingAngle.setVisible(false);
						louvreColour.setVisible(false);
						slatAngle.setVisible(false);
					} else if ((HSCO).equals(selected)) {
						windowConfig.setVisible(true);
						windowDepth.setVisible(true);
						shadingAngle.setVisible(false);
						louvreColour.setVisible(false);
						slatAngle.setVisible(false);
					} else if ((SSCO).equals(selected)) {
						windowConfig.setVisible(true);
						windowDepth.setVisible(true);
						shadingAngle.setVisible(true);
						louvreColour.setVisible(false);
						slatAngle.setVisible(false);
					} else if ((HEL).equals(selected)) {
						windowConfig.setVisible(false);
						windowDepth.setVisible(false);
						shadingAngle.setVisible(false);
						louvreColour.setVisible(true);
						slatAngle.setVisible(true);
					}
				}
			});

			return facadeTwoWindowShadingType;

		} else if ("facadeThreeWindowShadingType".equals(propertyId)) {
			
			final ComboBox facadeThreeWindowShadingType = new ComboBox("facadeThreeWindowShadingType");
			
			facadeThreeWindowShadingType.setNullSelectionAllowed(false);
			facadeThreeWindowShadingType.setInputPrompt("-- Select Shading Type --");
			for (int i = 0; i < shadingTypeArray.length; i++) {
				facadeThreeWindowShadingType.addItem(shadingTypeArray[i]);
			}
			facadeThreeWindowShadingType.setWidth("100%");
			facadeThreeWindowShadingType.setCaption("Shading Type");

			if (project.getFacadeThreeWindowShadingType() != null) {
				facadeThreeWindowShadingType.setValue(project.getFacadeThreeWindowShadingType());
			}
			
			facadeThreeWindowShadingType.addListener(new ValueChangeListener() {
				public void valueChange(ValueChangeEvent event) {
					String selected = (String) facadeThreeWindowShadingType.getValue();
					Slider windowDepth = (Slider) form.getField("facadeThreeWindowShadingDepth");
					ComboBox louvreColour = (ComboBox) form.getField("facadeThreeLouvreColour");
					ComboBox slatAngle = (ComboBox) form.getField("facadeThreeSlatAngle");
					ComboBox shadingAngle = (ComboBox) form.getField("facadeThreeShadingAngle");
					ComboBox windowConfig = (ComboBox) form.getField("facadeThreeWindowConfig");
					
					if (selected == null || windowDepth == null || shadingAngle == null
							|| louvreColour == null || slatAngle == null)
						return;
					
					if ((NONE).equals(selected)) {
						windowConfig.setVisible(false);
						windowDepth.setVisible(false);
						shadingAngle.setVisible(false);
						louvreColour.setVisible(false);
						slatAngle.setVisible(false);
					} else if ((HSCO).equals(selected)) {
						windowConfig.setVisible(true);
						windowDepth.setVisible(true);
						shadingAngle.setVisible(false);
						louvreColour.setVisible(false);
						slatAngle.setVisible(false);
					} else if ((SSCO).equals(selected)) {
						windowConfig.setVisible(true);
						windowDepth.setVisible(true);
						shadingAngle.setVisible(true);
						louvreColour.setVisible(false);
						slatAngle.setVisible(false);
					} else if ((HEL).equals(selected)) {
						windowConfig.setVisible(false);
						windowDepth.setVisible(false);
						shadingAngle.setVisible(false);
						louvreColour.setVisible(true);
						slatAngle.setVisible(true);
					}
				}
			});

			return facadeThreeWindowShadingType;
			
		} else if ("facadeFourWindowShadingType".equals(propertyId)) {
			
			final ComboBox facadeFourWindowShadingType = new ComboBox("facadeFourWindowShadingType");
			
			facadeFourWindowShadingType.setNullSelectionAllowed(false);
			facadeFourWindowShadingType.setInputPrompt("-- Select Shading Type --");
			for (int i = 0; i < shadingTypeArray.length; i++) {
				facadeFourWindowShadingType.addItem(shadingTypeArray[i]);
			}
			facadeFourWindowShadingType.setWidth("100%");
			facadeFourWindowShadingType.setCaption("Shading Type");

			if (project.getFacadeFourWindowShadingType() != null) {
				facadeFourWindowShadingType.setValue(project.getFacadeFourWindowShadingType());
			}
			
			facadeFourWindowShadingType.addListener(new ValueChangeListener() {
				public void valueChange(ValueChangeEvent event) {
					
					String selected = (String) facadeFourWindowShadingType.getValue();
					
					Slider windowShadingDepth = (Slider) form.getField("facadeFourWindowShadingDepth");
					ComboBox louvreColour = (ComboBox) form.getField("facadeFourLouvreColour");
					ComboBox slatAngle = (ComboBox) form.getField("facadeFourSlatAngle");
					ComboBox shadingAngle = (ComboBox) form.getField("facadeFourShadingAngle");
					ComboBox windowConfig = (ComboBox) form.getField("facadeFourWindowConfig");
					
					if (selected == null || windowShadingDepth == null || shadingAngle == null
							|| louvreColour == null || slatAngle == null)
						return;
					
					if ((NONE).equals(selected)) {
						windowConfig.setVisible(false);
						windowShadingDepth.setVisible(false);
						shadingAngle.setVisible(false);
						louvreColour.setVisible(false);
						slatAngle.setVisible(false);
					} else if ((HSCO).equals(selected)) {
						windowConfig.setVisible(true);
						windowShadingDepth.setVisible(true);
						shadingAngle.setVisible(false);
						louvreColour.setVisible(false);
						slatAngle.setVisible(false);
					} else if ((SSCO).equals(selected)) {
						windowConfig.setVisible(true);
						windowShadingDepth.setVisible(true);
						shadingAngle.setVisible(true);
						louvreColour.setVisible(false);
						slatAngle.setVisible(false);
					} else if ((HEL).equals(selected)) {
						windowConfig.setVisible(false);
						windowShadingDepth.setVisible(false);
						shadingAngle.setVisible(false);
						louvreColour.setVisible(true);
						slatAngle.setVisible(true);
					}
				}
			});

			return facadeFourWindowShadingType;
			
		} else if ("windowConfig".equals(propertyId)) {
			
			final ComboBox windowConfig = new ComboBox("windowConfig");
			
			windowConfig.setNullSelectionAllowed(false);
			windowConfig.setInputPrompt("-- Select Window Configuration --");
			for (int i = 0; i < windowConfigArray.length; i++) {
				windowConfig.addItem(windowConfigArray[i]);
			}
			windowConfig.setWidth("100%");
			windowConfig.setCaption("Window Config.");
			windowConfig.setVisible(false);

			windowConfig.addListener(new ValueChangeListener() {
				public void valueChange(ValueChangeEvent event) {
					String selected = (String) windowConfig.getValue();

					if (selected == null)
						return;
					
				}
			});

			return windowConfig;
		
		} else if ("facadeOneWindowConfig".equals(propertyId)) {
			
			final ComboBox facadeOneWindowConfig = new ComboBox("facadeOneWindowConfig");
			
			facadeOneWindowConfig.setNullSelectionAllowed(false);
			facadeOneWindowConfig.setInputPrompt("-- Select Window Configuration --");
			for (int i = 0; i < windowConfigArray.length; i++) {
				facadeOneWindowConfig.addItem(windowConfigArray[i]);
			}
			facadeOneWindowConfig.setWidth("100%");
			facadeOneWindowConfig.setCaption("Window Config.");
			facadeOneWindowConfig.setVisible(false);

			if ((HSCO).equals(project.getFacadeOneWindowShadingType()) || 
					(SSCO).equals(project.getFacadeOneWindowShadingType())) {
				if (project.getFacadeOneWindowConfig() != null) {
					facadeOneWindowConfig.setValue(project.getFacadeOneWindowConfig());
				}
				facadeOneWindowConfig.setVisible(true);
			}
			
			facadeOneWindowConfig.addListener(new ValueChangeListener() {
				public void valueChange(ValueChangeEvent event) {
					String selected = (String) facadeOneWindowConfig.getValue();

					if (selected == null)
						return;
					
				}
			});

			return facadeOneWindowConfig;
			
		} else if ("facadeTwoWindowConfig".equals(propertyId)) {
			
			final ComboBox facadeTwoWindowConfig = new ComboBox("facadeTwoWindowConfig");
			
			facadeTwoWindowConfig.setNullSelectionAllowed(false);
			facadeTwoWindowConfig.setInputPrompt("-- Select Window Configuration --");
			for (int i = 0; i < windowConfigArray.length; i++) {
				facadeTwoWindowConfig.addItem(windowConfigArray[i]);
			}
			facadeTwoWindowConfig.setWidth("100%");
			facadeTwoWindowConfig.setCaption("Window Config.");
			facadeTwoWindowConfig.setVisible(false);

			if ((HSCO).equals(project.getFacadeTwoWindowShadingType()) || 
					(SSCO).equals(project.getFacadeTwoWindowShadingType())) {
				if (project.getFacadeTwoWindowConfig() != null) {
					facadeTwoWindowConfig.setValue(project.getFacadeTwoWindowConfig());
				}
				facadeTwoWindowConfig.setVisible(true);
			}
			
			facadeTwoWindowConfig.addListener(new ValueChangeListener() {
				public void valueChange(ValueChangeEvent event) {
					String selected = (String) facadeTwoWindowConfig.getValue();

					if (selected == null)
						return;
					
				}
			});

			return facadeTwoWindowConfig;
			
		} else if ("facadeThreeWindowConfig".equals(propertyId)) {
			
			final ComboBox facadeThreeWindowConfig = new ComboBox("facadeThreeWindowConfig");
			
			facadeThreeWindowConfig.setNullSelectionAllowed(false);
			facadeThreeWindowConfig.setInputPrompt("-- Select Window Configuration --");
			for (int i = 0; i < windowConfigArray.length; i++) {
				facadeThreeWindowConfig.addItem(windowConfigArray[i]);
			}
			facadeThreeWindowConfig.setWidth("100%");
			facadeThreeWindowConfig.setCaption("Window Config.");
			facadeThreeWindowConfig.setVisible(false);

			if ((HSCO).equals(project.getFacadeThreeWindowShadingType()) || 
					(SSCO).equals(project.getFacadeThreeWindowShadingType())) {
				if (project.getFacadeThreeWindowConfig() != null) {
					facadeThreeWindowConfig.setValue(project.getFacadeThreeWindowConfig());
				}
				facadeThreeWindowConfig.setVisible(true);
			}
			
			facadeThreeWindowConfig.addListener(new ValueChangeListener() {
				public void valueChange(ValueChangeEvent event) {
					String selected = (String) facadeThreeWindowConfig.getValue();

					if (selected == null)
						return;
					
				}
			});

			return facadeThreeWindowConfig;
			
		} else if ("facadeFourWindowConfig".equals(propertyId)) {
			final ComboBox facadeFourWindowConfig = new ComboBox("facadeFourWindowConfig");
			
			facadeFourWindowConfig.setNullSelectionAllowed(false);
			facadeFourWindowConfig.setInputPrompt("-- Select Window Configuration --");
			for (int i = 0; i < windowConfigArray.length; i++) {
				facadeFourWindowConfig.addItem(windowConfigArray[i]);
			}
			facadeFourWindowConfig.setWidth("100%");
			facadeFourWindowConfig.setCaption("Window Config.");
			facadeFourWindowConfig.setVisible(false);

			if ((HSCO).equals(project.getFacadeFourWindowShadingType()) || 
					(SSCO).equals(project.getFacadeFourWindowShadingType())) {
				if (project.getFacadeFourWindowConfig() != null) {
					facadeFourWindowConfig.setValue(project.getFacadeFourWindowConfig());
				}
				facadeFourWindowConfig.setVisible(true);
			}
			
			facadeFourWindowConfig.addListener(new ValueChangeListener() {
				public void valueChange(ValueChangeEvent event) {
					String selected = (String) facadeFourWindowConfig.getValue();

					if (selected == null)
						return;
					
				}
			});

			return facadeFourWindowConfig;
			
		} else if ("windowDepth".equals(propertyId)) {
			 
			Slider slider = new Slider(0, 2, 2);
			slider.setCaption("Shading Depth [" + UNIT_m + "]");
			slider.setVisible(false);
			
			return slider;
			
		} else if ("facadeOneWindowShadingDepth".equals(propertyId)) {
			
			Slider slider = new Slider(0, 2, 2);
			slider.setCaption("Shading Depth [" + UNIT_m + "]");
			slider.setVisible(false);
			
			if ((HSCO).equals(project.getFacadeOneWindowShadingType()) || 
					(SSCO).equals(project.getFacadeOneWindowShadingType())) {
				slider.setVisible(true);
			}
			
			return slider;
			
		} else if ("facadeTwoWindowShadingDepth".equals(propertyId)) {
			
			Slider slider = new Slider(0, 2, 2);
			slider.setCaption("Shading Depth [" + UNIT_m + "]");
			slider.setVisible(false);

			if ((HSCO).equals(project.getFacadeTwoWindowShadingType()) || 
					(SSCO).equals(project.getFacadeTwoWindowShadingType())) {
				slider.setVisible(true);
			}
			
			return slider;
			
		} else if ("facadeThreeWindowShadingDepth".equals(propertyId)) {
			
			Slider slider = new Slider(0, 2, 2);
			slider.setCaption("Shading Depth [" + UNIT_m + "]");
			slider.setVisible(false);
			
			if ((HSCO).equals(project.getFacadeThreeWindowShadingType()) || 
					(SSCO).equals(project.getFacadeThreeWindowShadingType())) {
				slider.setVisible(true);
			}
			
			return slider;
			
		} else if ("facadeFourWindowShadingDepth".equals(propertyId)) {
			
			Slider slider = new Slider(0, 2, 2);
			slider.setCaption("Shading Depth [" + UNIT_m + "]");
			slider.setVisible(false);
			
			if ((HSCO).equals(project.getFacadeFourWindowShadingType()) || 
					(SSCO).equals(project.getFacadeFourWindowShadingType())) {
				slider.setVisible(true);
			}
			
			return slider;
			
		} else if (("shadingAngle".equals(propertyId)) ||
				("facadeOneShadingAngle".equals(propertyId)) ||
				("facadeTwoShadingAngle".equals(propertyId)) ||
				("facadeThreeShadingAngle".equals(propertyId)) ||
				("facadeFourShadingAngle".equals(propertyId))) {
			
			final ComboBox shadingAngle = new ComboBox(propertyId.toString());
			final String prop = propertyId.toString();
			
			shadingAngle.setNullSelectionAllowed(false);
			shadingAngle.setInputPrompt("-- Select Shading Angle --");
			for (int i = 0; i < slatAngleArray.length; i++) {
				shadingAngle.addItem(slatAngleArray[i]);
			}
			shadingAngle.setWidth("100%");
			shadingAngle.setCaption("Shading Angle [" + UNIT_deg + "]");
			shadingAngle.setVisible(false);
		
			if ((prop).equals("facadeOneShadingAngle") && (SSCO).equals(project.getFacadeOneWindowShadingType())) {
				shadingAngle.setVisible(true);
				if (project.getFacadeOneShadingAngle() != null) {
					shadingAngle.setValue(project.getFacadeOneShadingAngle());
				}
			}
			
			if ((prop).equals("facadeTwoShadingAngle") && (SSCO).equals(project.getFacadeTwoWindowShadingType())) {
				shadingAngle.setVisible(true);
				if (project.getFacadeTwoShadingAngle() != null) {
					shadingAngle.setValue(project.getFacadeTwoShadingAngle());
				}
			}
			
			if ((prop).equals("facadeThreeShadingAngle") && (SSCO).equals(project.getFacadeThreeWindowShadingType())) {
				shadingAngle.setVisible(true);
				if (project.getFacadeThreeShadingAngle() != null) {
					shadingAngle.setValue(project.getFacadeThreeShadingAngle());
				}
			}
			
			if ((prop).equals("facadeFourShadingAngle") && (SSCO).equals(project.getFacadeFourWindowShadingType())) {
				shadingAngle.setVisible(true);
				if (project.getFacadeFourShadingAngle() != null) {
					shadingAngle.setValue(project.getFacadeFourShadingAngle());
				}
			}
			
			shadingAngle.addListener(new ValueChangeListener() {
				public void valueChange(ValueChangeEvent event) {
					String selected = (String) shadingAngle.getValue();
		
					if (selected == null)
						return;
					
				}
			});
		
			return shadingAngle;
			
		} else if (("louvreColour".equals(propertyId)) ||
					("facadeOneLouvreColour".equals(propertyId)) ||
					("facadeTwoLouvreColour".equals(propertyId)) ||
					("facadeThreeLouvreColour".equals(propertyId)) ||
					("facadeFourLouvreColour".equals(propertyId))) {
			
			final ComboBox louvreColour = new ComboBox(propertyId.toString());
			final String prop = propertyId.toString();
			
			louvreColour.setNullSelectionAllowed(false);
			louvreColour.setInputPrompt("-- Select Louvre Colour --");
			louvreColour.addItem(DARK);
			louvreColour.addItem(LIGHT);
			louvreColour.setWidth("100%");
			louvreColour.setCaption("Louvre Colour");
			louvreColour.setVisible(false);

			if (prop.equals("facadeOneLouvreColour") && (HEL).equals(project.getFacadeOneWindowShadingType())) {
				louvreColour.setVisible(true);
			}
			
			if (prop.equals("facadeTwoLouvreColour") && (HEL).equals(project.getFacadeTwoWindowShadingType())) {
				louvreColour.setVisible(true);
			}
			
			if (prop.equals("facadeThreeLouvreColour") && (HEL).equals(project.getFacadeThreeWindowShadingType())) {
				louvreColour.setVisible(true);
			}
			
			if (prop.equals("facadeFourLouvreColour") && (HEL).equals(project.getFacadeFourWindowShadingType())) {
				louvreColour.setVisible(true);
			}

			louvreColour.addListener(new ValueChangeListener() {
				public void valueChange(ValueChangeEvent event) {
					String selected = (String) louvreColour.getValue();

					if (selected == null)
						return;

					if ((DARK).equals(selected)) {
						//building.setLouvreColour("Light");
					} else if ((LIGHT).equals(selected)) {
						//building.setLouvreColour("Dark");
					}
				}
			});

			return louvreColour;
			
		} else if (("slatAngle".equals(propertyId)) ||
					("facadeOneSlatAngle".equals(propertyId)) ||
					("facadeTwoSlatAngle".equals(propertyId)) ||
					("facadeThreeSlatAngle".equals(propertyId)) ||
					("facadeFourSlatAngle".equals(propertyId))) {
			
			final ComboBox slatAngle = new ComboBox(propertyId.toString());
			final String prop = propertyId.toString();
			
			slatAngle.setNullSelectionAllowed(false);
			slatAngle.setInputPrompt("-- Select Slat Angle --");
			for (int i = 0; i < slatAngleArray.length; i++) {
				slatAngle.addItem(slatAngleArray[i]);
			}
			slatAngle.setWidth("100%");
			slatAngle.setCaption("Slat Angle [" + UNIT_deg + "]");
			slatAngle.setVisible(false);
			
			if (prop.equals("facadeOneSlatAngle") && (HEL).equals(project.getFacadeOneWindowShadingType())) {
				slatAngle.setVisible(true);
			}
			
			if (prop.equals("facadeTwoSlatAngle") && (HEL).equals(project.getFacadeTwoWindowShadingType())) {
				slatAngle.setVisible(true);
			}
			
			if (prop.equals("facadeThreeSlatAngle") && (HEL).equals(project.getFacadeThreeWindowShadingType())) {
				slatAngle.setVisible(true);
			}
			
			if (prop.equals("facadeFourSlatAngle") && (HEL).equals(project.getFacadeFourWindowShadingType())) {
				slatAngle.setVisible(true);
			}
			
			slatAngle.addListener(new ValueChangeListener() {
				public void valueChange(ValueChangeEvent event) {
					String selected = (String) slatAngle.getValue();
		
					if (selected == null)
						return;
					
				}
			});
		
			return slatAngle;
			
		} else if (("facadeOneGlazingType".equals(propertyId)) ||
				("facadeTwoGlazingType".equals(propertyId)) ||
				("facadeThreeGlazingType".equals(propertyId)) ||
				("facadeFourGlazingType".equals(propertyId))) {

			final String prop = propertyId.toString();
			final ComboBox glazingType = new ComboBox(prop);
			
			glazingType.setNullSelectionAllowed(false);
			glazingType.setInputPrompt("-- Select Glazing Type --");
			for (int i = 0; i < glazingTypeArrayNew.length; i++) {
				glazingType.addItem(glazingTypeArrayNew[i]);
			}
			glazingType.setWidth("100%");
			glazingType.setCaption("Glazing Type");
			
			if (prop.equals("facadeOneGlazingType")) {
				if (project.getFacadeOneGlazingType() != null) {
					glazingType.setValue(project.getFacadeOneGlazingType());
				}
			}

			if (prop.equals("facadeTwoGlazingType")) {
				if (project.getFacadeTwoGlazingType() != null) {
					glazingType.setValue(project.getFacadeTwoGlazingType());
				}
			}
			
			if (prop.equals("facadeThreeGlazingType")) {
				if (project.getFacadeThreeGlazingType() != null) {
					glazingType.setValue(project.getFacadeThreeGlazingType());
				}
			}
			
			if (prop.equals("facadeFourGlazingType")) {
				if (project.getFacadeFourGlazingType() != null) {
					glazingType.setValue(project.getFacadeFourGlazingType());
				}
			}
			
			glazingType.addListener(new ValueChangeListener() {
				public void valueChange(ValueChangeEvent event) {
					
					String selected = (String) glazingType.getValue();
					
					if (selected == null)
						return;
					
					ComboBox glazingSpec = new ComboBox();
					
					if (prop.equals("facadeOneGlazingType")) {
						glazingSpec = (ComboBox) form.getField("facadeOneGlazingSpec");
					};
					
					if (prop.equals("facadeTwoGlazingType")) {
						glazingSpec = (ComboBox) form.getField("facadeTwoGlazingSpec");
					};
					
					if (prop.equals("facadeThreeGlazingType")) {
						glazingSpec = (ComboBox) form.getField("facadeThreeGlazingSpec");
					};
					
					if (prop.equals("facadeFourGlazingType")) {
						glazingSpec = (ComboBox) form.getField("facadeFourGlazingSpec");
					};
					
					if (glazingSpec == null)
						return;
					
					if ((DT_DG).equals(selected)) {
						glazingSpec.removeAllItems();
						for (int i = 0; i < solarTransArrayDG.length; i++) {
							glazingSpec.addItem(solarTransArrayDG[i]);
						}
						glazingSpec.setInputPrompt("-- Select Double Glazing Spec. --");
						glazingSpec.setVisible(true);
						
					} else if ((DT_TG).equals(selected)) {
						glazingSpec.removeAllItems();
						for (int i = 0; i < solarTransArrayTG.length; i++) {
							glazingSpec.addItem(solarTransArrayTG[i]);
						}
						glazingSpec.setInputPrompt("-- Select Triple Glazing Spec. --");
						glazingSpec.setVisible(true);
					}
					
				}
			});
		
			return glazingType;	
			
		} else if (("facadeOneGlazingSpec".equals(propertyId)) ||
				("facadeTwoGlazingSpec".equals(propertyId)) ||
				("facadeThreeGlazingSpec".equals(propertyId)) ||
				("facadeFourGlazingSpec".equals(propertyId))) {
		
			final ComboBox glazingSpec = new ComboBox(propertyId.toString());
			final String prop = propertyId.toString();
			
			glazingSpec.setNullSelectionAllowed(false);
			glazingSpec.setInputPrompt("-- Select Glazing Specification --");
			glazingSpec.setWidth("100%");
			glazingSpec.setCaption("Glazing Spec.");
			glazingSpec.setVisible(false);
			
			if (prop.equals("facadeOneGlazingSpec")) {
				if (project.getFacadeOneGlazingType() != null) {
					glazingSpec.removeAllItems();
					if ((DT_DG).equals(project.getFacadeOneGlazingType())) {
						for (int i = 0; i < solarTransArrayDG.length; i++) {
							glazingSpec.addItem(solarTransArrayDG[i]);
						}
						glazingSpec.setInputPrompt("-- Select Double Glazing Spec. --");
					} else if ((DT_TG).equals(project.getFacadeOneGlazingType())) {
						for (int i = 0; i < solarTransArrayTG.length; i++) {
							glazingSpec.addItem(solarTransArrayTG[i]);
						}
						glazingSpec.setInputPrompt("-- Select Triple Glazing Spec. --");
					}
					glazingSpec.setVisible(true);
				}
				if (project.getFacadeOneGlazingSpec() != null) {
					glazingSpec.setValue(project.getFacadeOneGlazingType());
				}
			}
			
			if (prop.equals("facadeTwoGlazingSpec")) {
				if (project.getFacadeTwoGlazingType() != null) {
					glazingSpec.removeAllItems();
					if ((DT_DG).equals(project.getFacadeTwoGlazingType())) {
						for (int i = 0; i < solarTransArrayDG.length; i++) {
							glazingSpec.addItem(solarTransArrayDG[i]);
						}
						glazingSpec.setInputPrompt("-- Select Double Glazing Spec. --");
					} else if ((DT_TG).equals(project.getFacadeTwoGlazingType())) {
						for (int i = 0; i < solarTransArrayTG.length; i++) {
							glazingSpec.addItem(solarTransArrayTG[i]);
						}
						glazingSpec.setInputPrompt("-- Select Triple Glazing Spec. --");
					}
					glazingSpec.setVisible(true);
				}
				if (project.getFacadeTwoGlazingSpec() != null) {
					glazingSpec.setValue(project.getFacadeTwoGlazingType());
				}
			}
			
			if (prop.equals("facadeThreeGlazingSpec")) {
				if (project.getFacadeThreeGlazingType() != null) {
					glazingSpec.removeAllItems();
					if ((DT_DG).equals(project.getFacadeThreeGlazingType())) {
						for (int i = 0; i < solarTransArrayDG.length; i++) {
							glazingSpec.addItem(solarTransArrayDG[i]);
						}
						glazingSpec.setInputPrompt("-- Select Double Glazing Spec. --");
					} else if ((DT_TG).equals(project.getFacadeThreeGlazingType())) {
						for (int i = 0; i < solarTransArrayTG.length; i++) {
							glazingSpec.addItem(solarTransArrayTG[i]);
						}
						glazingSpec.setInputPrompt("-- Select Triple Glazing Spec. --");
					}
					glazingSpec.setVisible(true);
				}
				if (project.getFacadeThreeGlazingSpec() != null) {
					glazingSpec.setValue(project.getFacadeThreeGlazingType());
				}
			}
			
			if (prop.equals("facadeFourGlazingSpec")) {
				if (project.getFacadeFourGlazingType() != null) {
					glazingSpec.removeAllItems();
					if ((DT_DG).equals(project.getFacadeFourGlazingType())) {
						for (int i = 0; i < solarTransArrayDG.length; i++) {
							glazingSpec.addItem(solarTransArrayDG[i]);
						}
						glazingSpec.setInputPrompt("-- Select Double Glazing Spec. --");
					} else if ((DT_TG).equals(project.getFacadeFourGlazingType())) {
						for (int i = 0; i < solarTransArrayTG.length; i++) {
							glazingSpec.addItem(solarTransArrayTG[i]);
						}
						glazingSpec.setInputPrompt("-- Select Triple Glazing Spec. --");
					}
					glazingSpec.setVisible(true);
				}
				if (project.getFacadeFourGlazingSpec() != null) {
					glazingSpec.setValue(project.getFacadeFourGlazingType());
				}
			}
			
			glazingSpec.addListener(new ValueChangeListener() {
				public void valueChange(ValueChangeEvent event) {
					String selected = (String) glazingSpec.getValue();
		
					if (selected == null)
						return;
					
				}
			});
		
			return glazingSpec;	
			
		} else if ("averageReflectanceOfInteriorSurfacesText".equals(propertyId)) {
			
			final ComboBox averageReflectanceOfInteriorSurfacesText = new ComboBox("averageReflectanceOfInteriorSurfacesText");
			
			averageReflectanceOfInteriorSurfacesText.setNullSelectionAllowed(false);
			averageReflectanceOfInteriorSurfacesText.setInputPrompt("-- Select Surface --");
			for (int i = 0; i < averageReflectanceArray.length; i++) {
				averageReflectanceOfInteriorSurfacesText.addItem(averageReflectanceArray[i]);
			}
			averageReflectanceOfInteriorSurfacesText.setWidth("100%");
			averageReflectanceOfInteriorSurfacesText.setCaption("Internal Surfaces");
		
			averageReflectanceOfInteriorSurfacesText.addListener(new ValueChangeListener() {
				public void valueChange(ValueChangeEvent event) {
					String selected = (String) averageReflectanceOfInteriorSurfacesText.getValue();
		
					if (selected == null)
						return;
					
				}
			});
		
			return averageReflectanceOfInteriorSurfacesText;
			
		} else if ("windowPercentageFrame".equals(propertyId)) {
			Slider slider = new Slider(0, 40, 0);
			slider.setCaption("% Frame");
			return slider;
			
		} else if ("facadeOnePercentageFrame".equals(propertyId)) {
			Slider slider = new Slider(0, 40, 0);
			slider.setCaption("% Frame");
			return slider;
			
		} else if ("facadeTwoPercentageFrame".equals(propertyId)) {
			Slider slider = new Slider(0, 40, 0);
			slider.setCaption("% Frame");
			return slider;
			
		} else if ("facadeThreePercentageFrame".equals(propertyId)) {
			Slider slider = new Slider(0, 40, 0);
			slider.setCaption("% Frame");
			return slider;
			
		} else if ("facadeFourPercentageFrame".equals(propertyId)) {
			Slider slider = new Slider(0, 40, 0);
			slider.setCaption("% Frame");
			return slider;
			
		} else if ("percentageGlazing".equals(propertyId)) {
			Slider slider = new Slider(0, 100, dpPercentage);
			slider.setCaption("% Glazing");
			slider.setMax(project.getMaxPercentageGlazing());
			return slider;

		} else if ("facadeOnePercentageTotalGlazedArea"
				.equals(propertyId)) {
			Slider slider = new Slider(0, 100, dpPercentage);
			slider.setCaption("% of Overall Glazing");
			return slider;

		} else if ("facadeTwoPercentageTotalGlazedArea"
				.equals(propertyId)) {
			Slider slider = new Slider(0, 100, dpPercentage);
			slider.setCaption("% of Overall Glazing");
			return slider;

		} else if ("facadeThreePercentageTotalGlazedArea"
				.equals(propertyId)) {
			Slider slider = new Slider(0, 100, dpPercentage);
			slider.setCaption("% of Overall Glazing");
			return slider;

		} else if ("facadeFourPercentageTotalGlazedArea"
				.equals(propertyId)) {
			Slider slider = new Slider(0, 100, dpPercentage);
			slider.setCaption("% of Overall Glazing");
			return slider;

		} else if ("facadeOneGlazedPercentage".equals(propertyId)) {
			Slider slider = new Slider(0, 100, dpPercentage);
			slider.setCaption("Facade % Glazed");
			if (project.isFacadeOneGlazedAreaLock())
				slider.setEnabled(false);
			return slider;

		} else if ("facadeTwoGlazedPercentage".equals(propertyId)) {
			Slider slider = new Slider(0, 100, dpPercentage);
			slider.setCaption("Facade % Glazed");
			if (project.isFacadeTwoGlazedAreaLock())
				slider.setEnabled(false);
			return slider;

		} else if ("facadeThreeGlazedPercentage".equals(propertyId)) {
			Slider slider = new Slider(0, 100, dpPercentage);
			slider.setCaption("Facade % Glazed");
			if (project.isFacadeThreeGlazedAreaLock())
				slider.setEnabled(false);
			return slider;

		} else if ("facadeFourGlazedPercentage".equals(propertyId)) {
			Slider slider = new Slider(0, 100, dpPercentage);
			slider.setCaption("Facade % Glazed");
			if (project.isFacadeFourGlazedAreaLock())
				slider.setEnabled(false);
			return slider;

		} else if ("uValueRoof".equals(propertyId)) {
			Slider slider = new Slider(0, 1, 2);
			slider.setCaption("U-value Roof [" + UNIT_wm2k + "]");
			slider.setMin(0.1d);
			slider.setMax(0.25d);
			if ((FT_NB).equals(project.getFacadeType())) {
				slider.setMin(0.1d);
				slider.setMax(0.25d);
			}
			if ((FT_REP).equals(project.getFacadeType())
				|| (FT_REF).equals(project.getFacadeType())) {
				slider.setMin(0.1d);
				slider.setMax(0.35d);
			}
			return slider;

		} else if ("uValueGroundFloor".equals(propertyId)) {
			Slider slider = new Slider(0, 1, 2);
			slider.setCaption("U-value Ground Floor [" + UNIT_wm2k + "]");
			slider.setMin(0.1d);
			slider.setMax(0.37d);
			if ((FT_NB).equals(project.getFacadeType())) {
				slider.setMin(0.1d);
				slider.setMax(0.37d);
			}
			if ((FT_REP).equals(project.getFacadeType())
				|| (FT_REF).equals(project.getFacadeType())) {
				slider.setMin(0.1d);
				slider.setMax(0.6d);
			}
			return slider;

		} else if ("uValueWalls".equals(propertyId)) {
			Slider slider = new Slider(0, 1, 2);
			slider.setCaption("U-value Walls [" + UNIT_wm2k + "]");
			slider.setMin(0.1d);
			slider.setMax(0.27d);
			if ((FT_NB).equals(project.getFacadeType())) {
				slider.setMin(0.1d);
				slider.setMax(0.27d);
			}
			if ((FT_REP).equals(project.getFacadeType())
				|| (FT_REF).equals(project.getFacadeType())) {
				slider.setMin(0.1d);
				slider.setMax(0.6d);
			}
			return slider;

		} else if ("uValueGlazing".equals(propertyId)) {
			Slider slider = new Slider(0, 1, 2);
			slider.setCaption("U-value Glazing [" + UNIT_wm2k + "]");
			slider.setMin(0.6d);
			slider.setMax(2.20d);
			if ((FT_NB).equals(project.getFacadeType())) {
				slider.setMin(0.6d);
				slider.setMax(2.20d);
			}
			if ((FT_REP).equals(project.getFacadeType())
				|| (FT_REF).equals(project.getFacadeType())) {
				slider.setMin(0.6d);
				slider.setMax(2.20d);
			}
			return slider;

		} else if ("facadePerformance".equals(propertyId)) {
			Slider slider = new Slider(100, 0, 2);
			slider.setCaption("Performance Level [" + UNIT_wm2k + "]");
			slider.setMin(project.getFacadeExcellence());
			return slider;
			
		} else if ("facadePerformanceValue".equals(propertyId)) {
			((TextField) field).setCaption("Selected Overall Thermal Performance [" + UNIT_wm2k + "]");
			
		} else if ("projName".equals(propertyId)) {
			((TextField) field).setCaption("Project Name");
			
		} else if ("projDescription".equals(propertyId)) {
			TextArea textearea = new TextArea();
			textearea.setRows(3);
			textearea.setWidth("100%");
			textearea.setCaption("Project Description");
			textearea.setRequired(true);
			textearea.setNullSettingAllowed(true);
			textearea.setNullRepresentation("");
			return textearea;

		} else if ("projNumber".equals(propertyId)) {
			((TextField) field).setCaption("Project Number");
			((TextField) field).setNullSettingAllowed(true);
			((TextField) field).setNullRepresentation("");
			
		} else if ("gpsLocation".equals(propertyId)) {
			((TextField) field).setCaption("GPS - Co-ordinates");
		
		} else if (("facadeOneSurroundingFeaturesAverageHeight".equals(propertyId))
				|| ("facadeTwoSurroundingFeaturesAverageHeight".equals(propertyId))
				|| ("facadeThreeSurroundingFeaturesAverageHeight".equals(propertyId))
				|| ("facadeFourSurroundingFeaturesAverageHeight".equals(propertyId))) {
			((TextField) field).setCaption("Average Height [m]");
			((TextField) field).addValidator(doubleValidator);
			
		} else if (("facadeOneSurroundingFeaturesAverageDistance".equals(propertyId))
				|| ("facadeTwoSurroundingFeaturesAverageDistance".equals(propertyId))
				|| ("facadeThreeSurroundingFeaturesAverageDistance".equals(propertyId))
				|| ("facadeFourSurroundingFeaturesAverageDistance".equals(propertyId))) {
			((TextField) field).setCaption("Average Distance [m]");
			((TextField) field).addValidator(doubleValidator);
			
		} else if (("facadeOneSolarTransmittanceRO".equals(propertyId))
				|| ("facadeTwoSolarTransmittanceRO".equals(propertyId))
				|| ("facadeThreeSolarTransmittanceRO".equals(propertyId))
				|| ("facadeFourSolarTransmittanceRO".equals(propertyId))) {
			((TextField) field).setCaption("Solar Trans.");
		
		} else if (("facadeOneShadingFactorRO".equals(propertyId))
				|| ("facadeTwoShadingFactorRO".equals(propertyId))
				|| ("facadeThreeShadingFactorRO".equals(propertyId))
				|| ("facadeFourShadingFactorRO".equals(propertyId))) {
			((TextField) field).setCaption("Shading Factor");
		
		} else if ("facadeOneAvgDailySolarLoadPerFloorValue".equals(propertyId)) {
			((TextField) field).setCaption("Fa�ade One - Average Daily Solar Load per Floor [" + UNIT_wm2 + "]");
			
		} else if ("facadeTwoAvgDailySolarLoadPerFloorValue".equals(propertyId)) {
			((TextField) field).setCaption("Fa�ade Two - Average Daily Solar Load per Floor [" + UNIT_wm2 + "]");
			
		} else if ("facadeThreeAvgDailySolarLoadPerFloorValue".equals(propertyId)) {
			((TextField) field).setCaption("Fa�ade Three - Average Daily Solar Load per Floor [" + UNIT_wm2 + "]");
			
		} else if ("facadeFourAvgDailySolarLoadPerFloorValue".equals(propertyId)) {
			((TextField) field).setCaption("Fa�ade Four - Average Daily Solar Load per Floor [" + UNIT_wm2 + "]");
			
		} else if ("facadeOneGlazedPercentageValue".equals(propertyId)) {
			((TextField) field).setCaption("Fa�ade One - % Glazed");
			
		} else if ("facadeTwoGlazedPercentageValue".equals(propertyId)) {
			((TextField) field).setCaption("Fa�ade Two - % Glazed");
			
		} else if ("facadeThreeGlazedPercentageValue".equals(propertyId)) {
			((TextField) field).setCaption("Fa�ade Three - % Glazed");
			
		} else if ("facadeFourGlazedPercentageValue".equals(propertyId)) {
			((TextField) field).setCaption("Fa�ade Four - % Glazed");
			
		} else if ("facadeExcellence".equals(propertyId)) {
			((TextField) field).setCaption("Fa�ade Excellence [" + UNIT_wm2k + "]");
	
		} else if ("percentageGlazingValue".equals(propertyId)) {
			((TextField) field).setCaption("Selected Glazing Quantity [" + UNIT_perc + "]");
			
		} else if ("uValueRoofValue".equals(propertyId)) {
			((TextField) field).setCaption("Selected [" + UNIT_wm2k + "]");
			
		} else if ("uValueGroundFloorValue".equals(propertyId)) {
			((TextField) field).setCaption("Selected [" + UNIT_wm2k + "]");
			
		} else if ("uValueGlazingValue".equals(propertyId)) {
			((TextField) field).setCaption("Selected [" + UNIT_wm2k + "]");
			
		} else if ("uValueWallsValue".equals(propertyId)) {
			((TextField) field).setCaption("Selected [" + UNIT_wm2k + "]");
			
		} else if ("glazingWallRatio".equals(propertyId)) {
			((TextField) field).setCaption("Glazing to Wall Ratio");
			
		} else if ("facadeOneDiffuseTransmittanceValue".equals(propertyId) ||
				"facadeTwoDiffuseTransmittanceValue".equals(propertyId) ||
				"facadeThreeDiffuseTransmittanceValue".equals(propertyId) ||
				"facadeFourDiffuseTransmittanceValue".equals(propertyId)) {
			((TextField) field).setCaption("Diffuse Transmittance");
			
		} else if ("facadeOneSolarTransmittance".equals(propertyId) ||
				"facadeTwoSolarTransmittance".equals(propertyId) ||
				"facadeThreeSolarTransmittance".equals(propertyId) ||
				"facadeFourSolarTransmittance".equals(propertyId)) {
			((TextField) field).setCaption("Solar Transmittance");
			
		} else if ("facadeOneWindowSolarTransmittance".equals(propertyId) ||
				"facadeTwoWindowSolarTransmittance".equals(propertyId) ||
				"facadeThreeWindowSolarTransmittance".equals(propertyId) ||
				"facadeFourWindowSolarTransmittance".equals(propertyId)) {
			((TextField) field).setCaption("Solar Transmittance");
	
		} else if ("latitude".equals(propertyId)) {
			((TextField) field).setCaption("Latitude [" + UNIT_deg + "]");
			
		} else if ("longitude".equals(propertyId)) {
			((TextField) field).setCaption("Longitude [" + UNIT_deg + "]");
			
		} else if ("volume".equals(propertyId)) {
			((TextField) field).setCaption("Volume [" + UNIT_m3 + "]");
			
		} else if ("totalFacadeArea".equals(propertyId)) {
			((TextField) field).setCaption("Total Facade Area [" + UNIT_m2 + "]");
			
		} else if ("length".equals(propertyId)) {
			((TextField) field).setCaption("Length [" + UNIT_m + "]");
			((TextField) field).addValidator(doubleValidator);
			
		} else if ("width".equals(propertyId)) {
			((TextField) field).setCaption("Width [" + UNIT_m + "]");
			((TextField) field).addValidator(doubleValidator);
			
		} else if ("floorToFloor".equals(propertyId)) {
			((TextField) field).setCaption("Floor to Floor Height [" + UNIT_m + "]");
			((TextField) field).addValidator(doubleValidator);
			
		} else if ("overallBuildingHeight".equals(propertyId)) {
			((TextField) field).setCaption("Overall Building Height [" + UNIT_m + "]");
			((TextField) field).addValidator(doubleValidator);
			
		} else if ("floorToCeiling".equals(propertyId)) {
			((TextField) field).setCaption("Floor to Ceiling Height [" + UNIT_m + "]");
			((TextField) field).addValidator(doubleValidator);
			
		} else if ("wallThickness".equals(propertyId)) {
			((TextField) field).setCaption("External Wall Thickness [" + UNIT_m + "]");
			((TextField) field).addValidator(doubleValidator);
			
		} else if ("maintenanceFactorValue".equals(propertyId)) {
			((TextField) field).setCaption("Maintenance Factor");
			
		} else if (propertyId.toString().length() > 10 && ("WindowHH".equals(
						propertyId.toString().substring(
								 propertyId.toString().length() - 10, propertyId.toString().length() - 2
						)))) {
			//String value = propertyId.toString();
			//int length = value.length();
			//int floornum = value.charAt(length -1) - 48;
			//String floorText = floorNames[floornum];
			
			((TextField) field).setVisible(false);
			((TextField) field).setCaption(null);
			((TextField) field).setRequired(false);
			((TextField) field).addValidator(doubleValidator);
			
		} else if (propertyId.toString().length() > 10 && ("WindowCH".equals(
				propertyId.toString().substring(
						 propertyId.toString().length() - 10, propertyId.toString().length() - 2
				)))) {
			//String value = propertyId.toString();
			//int length = value.length();
			//int floornum = value.charAt(length -1) - 48;
			//String floorText = floorNames[floornum];
			
			((TextField) field).setVisible(false);
			((TextField) field).setCaption(null);
			((TextField) field).setRequired(false);
			((TextField) field).addValidator(doubleValidator);
			
		} else if (propertyId.toString().length() > 10 && ("WindowRV".equals(
				propertyId.toString().substring(
						 propertyId.toString().length() - 10, propertyId.toString().length() - 2
				)))) {
			//String value = propertyId.toString();
			//int length = value.length();
			//int floornum = value.charAt(length -1) - 48;
			//String floorText = floorNames[floornum];
			
			((TextField) field).setVisible(false);
			((TextField) field).setCaption(null);
			((TextField) field).setRequired(false);
			((TextField) field).addValidator(doubleValidator);
			
		} else if (("floor0".equals(propertyId)) || ("floor1".equals(propertyId))
				|| ("floor2".equals(propertyId)) || ("floor3".equals(propertyId))
				|| ("floor4".equals(propertyId)) || ("floor5".equals(propertyId))
				|| ("floor6".equals(propertyId)) || ("floor7".equals(propertyId))
				|| ("floor8".equals(propertyId)) || ("floor9".equals(propertyId))
				|| ("floor10".equals(propertyId)) || ("floor11".equals(propertyId))
				|| ("floor12".equals(propertyId)) || ("floor13".equals(propertyId))
				|| ("floor14".equals(propertyId)) || ("floor15".equals(propertyId))
				|| ("floor".equals(propertyId))  || ("windowHH".equals(propertyId))
				|| ("windowCH".equals(propertyId)) || ("windowRV".equals(propertyId))) {
			
			if (("floor".equals(propertyId)) || ("windowHH".equals(propertyId))
					|| ("windowCH".equals(propertyId)) || ("windowRV".equals(propertyId)))
				((TextField) field).setVisible(true);
			else
				((TextField) field).setVisible(false);
			
			((TextField) field).setCaption(null);
			((TextField) field).setRequired(false);			
			
		} else {
			((TextField) field).addValidator(doubleValidator);
		}
		
		field.setWidth("100%");
		return field;
	}

}
